<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .container {
        display: flex;
        height: 100px;
      }
      .box1 {
        /* width: 187.5px; */
        width: 50rem;
        height: 100%;
        background-color: yellow;
      }
      .box2 {
        /* width: 187.5px; */
        width: 50rem;
        height: 100%;
        background-color: green;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="box1"></div>
      <div class="box2"></div>
    </div>
    <script>
      // rem适配：动态设置（根据屏幕大小）根标签字体大小
      /*
        ui设计稿（iphone6/7/8）有一个元素宽度100px，请问转化为多少rem？
          100px --> xrem
          1rem = 375 / 100 px
          100 / 3.75 = x / 1   x = 26.667px
          1rem的实际大小 = （屏幕宽度 / 平分的份数）
          
          设计稿元素的大小 / 1rem的实际大小
      */
      function setFontSize() {
        document.documentElement.style.fontSize =
          document.documentElement.clientWidth / 100 + "px";
      }

      setFontSize();

      window.onresize = setFontSize;
    </script>
  </body>
</html>
